function getUserInfo() {
    $.ajax({
        url: '/my/userinfo',
        /* headers :{
            Authorization: localStorage.getItem('token')
        }, */
        success(res) {
            layui.layer.msg(res.message)
            if (res.status !== 0) {
                return
            }
            // console.log(res);
            render(res.data)
        },

    })
}
//渲染头像
function render(usrIfo) {
    var usrName = usrIfo.nickname || usrIfo.username
    $('#usrName').text(usrName)
    if (usrIfo.user_pic) {
        $('.img-avatar').attr('src', usrIfo.user_pic).show()
        $('.text-avatar').hide()
    } else {
        $('.text-avatar').text(usrName[0].toUpperCase()).show()
        $('.img-avatar').hide()
    }
}
$(function () {
    getUserInfo()




    //退出
    $('#back').on('click', function (e) {
        e.preventDefault()
        layui.layer.confirm('is not?', { icon: 3, title: '提示' }, function (index) {
            localStorage.removeItem('token')
            location.href = '/login.html'
            //do something
            layer.close(index);
        });
    })
})